<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<meta charset="utf-8">
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta content="width=device-width, minimum-scale=1,initial-scale=1, maximum-scale=1, user-scalable=1" id="viewport" name="viewport" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style" />
	<meta content="telephone=no" name="format-detection" />
	<link type="text/css" rel="stylesheet" href="../../template/css/com/com.css"/>
	<link type="text/css" rel="stylesheet" href="../../template/css/list/style.css"/>
	<link rel="stylesheet" href="../../resource/weuimin.css"/>
	<link rel="stylesheet" href="../../resource/example.css"/>

	<script src="../../template/js/jquery.js"></script>
	<script src="../../template/js/com/com.js"></script>
	<script src="../../template/js/com/template.js"></script>
	<script src="../../resource/my.js"></script>
	<script src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/aes.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
	<script type="text/javascript" src="../../script/modeecb.js"></script>
    <script type="text/javascript" src="../../script/tmd5.js"></script>
    <script type="text/javascript" src="../../script/constants.js"></script>
      <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
   	<style type="text/css">
   		#pxui-form .shxx{
	   		border: 1px solid #f7bfbf;
	    	padding: 5px;
	    	width:98%;
    	}
    	#pxui-form p{padding-left:3%;width: 95%;}
    	#dzlist .addr_checkbox{float:left;margin:8px 5px 0 0;}
    	#kpxx .kpxz,#kpxx .sfkp{float:left;margin:6px 5px 0 0;}
    	.dzsel{width:31%;margin:0 1% 10px 0;padding:5px;border:1px solid #f7bfbf;}
    	.pxui-form-info{padding:0px;}
    	.page-title{margin-bottom:10px;}
    	.pxui-area .pxui-form-info {margin: 5px 10px;}
    	.noscroll,
		.noscroll body {
		    overflow: hidden;
		}
		.noscroll body {
		    position: relative;
		}
    	#bg{position: absolute;  top: 0%;  left: 0%;  width: 100%;background-color: black;  z-index:1001;  -moz-opacity: 0.7;  opacity:.70;  filter: alpha(opacity=70);}
   	</style>
  </head>
  <body>
  <div style="display:none" id="bg"></div>  
   <header id="statusBar">
    <div id="jsheader">
        <nav id="jsnav">
            <a id="jsleft" tapmode="" onclick="api.closeToWin({name: 'root'});">
                <span>主页</span>
            </a>
            <div id="jsmiddle">
                <strong id="jstitle">职场生活</strong>
            </div>
            <a id="jsright">
              <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
            </a>
        </nav>
    </div>
    </header>
    <div class="com-content style-page">
		<!-- <div class="com-header-area" id="js-com-header-area">
			<a href="" class="com-header-logo"
				style="width:100%;color:#FFFFFF;text-align:center;font-size:24px;">职场生活</a>
			<div class="clear"></div>
		</div> -->
		<div class="com-header-area" id="js-com-header-area">
			<!-- <a href="" class="com-header-logo"
				style="width:100%;color:#FFFFFF;text-align:center;font-size:20px;">职场生活</a> -->
				<img src="../../image/tb.png" style="width:100%;"/>
				<ul class="menu_ul">
					<a href="main.html" class="selected"><li>首  页</li></a>
					<a href="history.html"><li>历 史 订 单</li></a>
					<a href="bill.html"><li>购 物 筐</li></a>
				</ul>
			<dfn></dfn>
			<div class="clear"></div>
		</div>

		<div class="com-content-area" id="js-com-content-area" style="padding:0px 0 10px 0;">
<!-- 			<div class="pxui-tab pxui-tab-nav pxui-tab-no-top">
				<a href="main.html"><i></i>首 页<span></span></a>
				<a href="history.html"><i></i>历史订单<span></span></a>
				<a href="bill.html" class="selected"><i></i>购物框<span></span></a>
			</div> -->
			<div class="page-role cart-page cart-index-page" >
				<div class="page-title">
					<a onclick="api.closeWin()" class="return">返 回</a>购物筐
				</div>
				<form id="js-form" action="/order/trolly" method="post">
					<div class="pxui-area goodlist">
						<!--div style="text-align:center;padding: 50px 0;font-size: 16px;">您当前购物车空荡荡的，赶快去添加吧！
						<br/>
						<a href="../../default.htm">返回首页</a>
						</div-->
						<div id="pxui-form" class="pxui-form-info" >
							<b>收货信息</b>
							<div id="dzlist">
								数据加载中...
							</div>

							<p>
								<b>新增地址</b>：
								<input id="box0" type="checkbox" class="addr_checkbox" style="float:left;margin:8px 5px 0 0;" onclick="selectAddr(0)"/><br/>
								<label>收货人姓名 (必填)：</label><input id="sh_mc" class="shxx" value=""/><br/>
								<label>联系电话 (必填)：</label><input id="sh_dh" class="shxx" value=""/><br/>
								<label>详细地址(必填) ：</label><br/>
								<select class="dzsel" id="address_sheng" onchange="loadShi()">

								</select>
								<select class="dzsel" id="address_shi" onchange="dqdm()">

								</select>
								<select class="dzsel" id="address_qx">

								</select>
								<input id="sh_dz" class="shxx" value=""/>
							</p>
						 </div>
					</div>
					<div class="pxui-area goodlist" style="margin-top:12px;">
						 <div id="pxui-form" class="pxui-form-info">
							<b>开票信息</b>
							<p id="kpxx">
								<label style="float:left;">是否发票：</label>
								<font>
									<input type="checkbox" class="sfkp" id="sfkp1" onclick="selectSfkp(1)"/><font style="float:left;">是&nbsp;&nbsp;&nbsp;&nbsp;</font>
									<input type="checkbox" class="sfkp" id="sfkp2" onclick="selectSfkp(2)" checked="checked"/><font style="float:left;">否</font>
								</font>
								<br class="bkp"/>
								<label class="bkp" style="float:left;">发票选择：</label>
								<font class="bkp" style="float:left;">
									<input type="checkbox" class="kpxz" id="kpxz1" onclick="selectKpxz(1)"/><font style="float:left;">个人&nbsp;&nbsp;&nbsp;&nbsp;</font>
									<input type="checkbox" class="kpxz" id="kpxz2" onclick="selectKpxz(2)"/><font style="float:left;">单位</font>
								</font>
								<br class="bkp"/>
								<label class="bkp">发票抬头 (必填)：</label><input id="kp_mc" class="shxx bkp" value=""/><br/>
								<font id="gskpxx" class="bkp"><label class="tax">税  号：</label><input id="kp_sh" class="shxx" value=""/><br/>
								<label class="tax">地址电话：</label><input id="kp_dzdh" class="shxx"/>
								<label class="tax">开户行账号：</label><input id="kp_khh" class="shxx"/></font>
								<label class="bkp">发票类型：</label>
								<select class="bkp" style="width:60%;margin-top:10px;padding:5px;" id="kp_fplx">
									<option value="Dz">电子发票</option>
								</select>
							</p>
						</div>
						<div style="font-weight:bold;width:98%;float:left;text-align:right;">
							总计：<label class="pxui-color-red" id="zje"></label> <input
								type="button" id="pay_button" class="pxui-light-button addtocart" value="支  付" onclick="payMethod()" />
						</div>
					</div>
				</form>
			</div>
		</div>
		   <div id="loadingToast" style="display:none;">
		        <div class="weui-mask_transparent"></div>
		        <div class="weui-toast">
		            <i class="weui-loading weui-icon_toast"></i>
		            <p class="weui-toast__content">数据提交中...</p>
		        </div>
			</div>
			<div id="msgToast" style="display:none;">
		        <div class="weui-mask_transparent"></div>
		        <div class="weui-toast">
		            <i class="weui-loading weui-icon_toast"></i>
		            <p class="weui-toast__content">地址数据获取中...</p>
		        </div>
			</div>

	</div>
		<div class="com-footer-area footer" id="js-com-footer" style="width:100%;">
				<img src="../../image/db.png" style="width:100%;"/>
			</div>
  </body>
     	<script type="text/javascript">
     	var allPrice = "";
     	var allspmc = "";
     	var orderid = "";
     	var seli = 0;
     	var _openid = "";
     	apiready=function(){
     	    if(api.systemType == "ios"){
			   document.getElementById("statusBar").style.background = "#298cb4";
			}
     	    $api.fixStatusBar( $api.dom('header') );
	     	api.addEventListener({
	          name:'keyback'
		    },function(ret,err){
		     if("paymethod"==$api.getStorage("frame") && $api.getStorage("upay") == ""){
			     $api.setStorage("frame","");
			     document.getElementById("bg").style.display="none";
			     $('html').removeClass('noscroll');
			     api.closeFrame({
					    name: 'zffs'
					});
		    }else if("unionpay"==$api.getStorage("upay") && $api.getStorage("frame") == ""){
		    	 $api.setStorage("upay","");
			     document.getElementById("bg").style.display="none";
			     $('html').removeClass('noscroll');
			     api.closeFrame({
				    name: 'ylzff'
				 });	   
		    }else{
		       api.closeWin({});
		    }
		   });
	        var header = $api.byId('jsheader');
		        api.addEventListener({
			        name:'alipayEndY'
		        },function(ret,err){
		        	cart.clear();
		        	window.location.href = 'main.html';
	
		        });
		        api.addEventListener({
			        name:'alipayEndN'
		        },function(ret,err){
		        	window.location.href = 'main.html';
		        });
	        if(api.systemType=='ios'){
	    			$api.fixIos7Bar(header);
	    		}
	
	     	_openid = $api.getStorage('openid');
	     	api.sendEvent({
			    name: 'close',
			    extra: {
			        key: 2
			    }
			 });
	          selectSfkp(2);
	     	  orderid = api.pageParam.orderid;
	     	  allPrice = api.pageParam.allPrice;
	     	  allspmc = api.pageParam.allspmc;
	     	  $("#zje").html("￥"+allPrice);
	     	  addr(orderid);
	     	  loadSheng();
     	}


     	var dzObj = null;
     	var seli = 0;

   	function loadSheng(){

   		$("#msgToast").show();
   		var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
            var data = ret.json;
		    	var html = "";
		    	for(var i=0;i<data.length;i++){
		    		if(data[i].mc.indexOf("四川") == 0){
		    			html += "<option value=\"" + data[i].dm + "\" selected=\"selected\">"+ data[i].mc + "</option>"
		    		}else{
		    			html += "<option value=\"" + data[i].dm + "\">"+ data[i].mc + "</option>";
		    		}
		    	}
		    	$("#address_sheng").html(html);
		    	$("#msgToast").hide();
		    	if(seli == 0){
		    		//判断是省内还是省外
			    	var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
			    	if(num == 0){
			    		$("#zje").html("￥" + parseInt(allPrice));
			    	}else{
			    		$("#zje").html("￥" + (parseInt(allPrice) + 12.00));
			    	}
		    	}
		    	loadShi();
        }
	    var content = {"dqdm":"100000","openid":_openid,"wlfs":1};
	    apiAjax(JSON.stringify(content),url.dqurl,callback);
   	}

 	function loadShi(){
 	    var sdm = $("#address_sheng").val();
 		if(seli == 0){
	 		//判断是省内还是省外
	 		var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
	    	if(num == 0){
	    		$("#zje").html("￥"+allPrice);
	    	}else{
	    		$("#zje").html("￥" + (parseInt(allPrice) + 12.00));
	    	}
 		}

 		$("#msgToast").show();
 		var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
            var data = ret.json;

		    	var html = "";
		    	for(var i=0;i<data.length;i++){
		    		html += "<option value=\"" + data[i].dm + "\">"+ data[i].mc + "</option>"
		    	}
		    	$("#address_shi").html(html);
		    	$("#msgToast").hide();
		    	dqdm();
        }
 		var content = {"dqdm":sdm,"openid":_openid,"wlfs":1};
	    apiAjax(JSON.stringify(content),url.dqurl,callback);
   	}




   	function dqdm(){
   		$("#msgToast").show();
   		var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
             $("#msgToast").hide();
	    	var data = ret.json;
	    	var html = "";
	    	for(var i=0;i<data.length;i++){
	    		html += "<option value=\"" + data[i].dm + "\">"+ data[i].mc + "</option>"
	    	}
	    	$("#address_qx").html(html);
        }
	    var content = {"dqdm":$("#address_shi").val(),"openid":_openid,"wlfs":1};
	    apiAjax(JSON.stringify(content),url.dqurl,callback);
   	}

   	function selectAddr(i){
   		$(".addr_checkbox").attr("checked", false);
   		$("#box" + i).attr("checked", true);
   		seli = i;
   		if(i > 0){
   			var num = dzObj[i-1].dz.indexOf("四川");
	  		if(num == 0){
		    	$("#zje").html("￥"+allPrice);
		    }else{
		    	$("#zje").html("￥" + (parseInt(allPrice) + 12.00));
		    }
   		}else{
   		    
   			//判断是省内还是省外
	    	var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
	    	if(num == 0){
	    		$("#zje").html("￥"+allPrice);
	    	}else{
	    		$("#zje").html("￥" + (parseInt(allPrice)+ 12.00));
	    	}
   		}
   	}

   	function selectSfkp(i){
   		$(".sfkp").attr("checked", false);
   		$("#sfkp" + i).attr("checked", true);
   		if(i==1){
   			$(".bkp").show();
   			$("#kp_sh").show();
   			$("#kp_dzdh").show();
   			$("#kp_khh").show();
   			$(".tax").show();
   		}else{
   		    $("#kp_sh").hide();
   		    $("#kp_dzdh").hide();
   		    $("#kp_khh").hide();
   			$(".bkp").hide();
   			$(".tax").hide();
   		}
   	}

   	function selectKpxz(i){
   		$(".kpxz").attr("checked", false);
   		$("#kpxz" + i).attr("checked", true);
   		if(i==1){
   			$("#gskpxx").hide();
   			$("#kp_mc").val("个人");
   		}else{
   			$("#gskpxx").show();
   			$("#kp_mc").val("单位");
   		}
   	}

   	function addr(_orderid){
        var callback = function(data, err){
            //console.log(JSON.stringify(ret));
            if(data.msg !=null){
	    		$("#pay_button").hide();
	    		$("#dzlist").html('');
	    		selectKpxz(1);
	    		alert(data.msg);
	    	}else{
	    		if(data.addr != null){
		    		$("#sh_mc").val(data.addr.mc);
		    		$("#sh_dh").val(data.addr.dh);
		    		$("#sh_dz").val(data.addr.dz);
		    	}
	    		if(data.addrs != null && data.addrs.length > 0){
	    			dzObj = data.addrs;
	    			var html ="";
	    			for(var i=1;i<data.addrs.length + 1;i++){
	    				if(data.addrs[i-1].dz.indexOf(",") != -1){
		    				if(data.addrs[i-1].status == 0){
		    					//判断是省内还是省外
		    			 		var num = data.addrs[i-1].dz.indexOf("四川");
		    			    	if(num == 0){
		    			    		$("#zje").html("￥" + allPrice);
		    			    	}else{
		    			    		$("#zje").html("￥" + (parseInt(allPrice) + 12.00));
		    			    	}
		    					seli = i;
		    					html +="<p>"
									+ " <b> 地址"+ i +" </b>："
									+ " <input type=\"checkbox\" checked id=\"box"+ i + "\" class=\"addr_checkbox\" onclick=\"selectAddr("+ i + ")\"/><br/>"
									+ " <label>收货人姓名 ：</label>" + data.addrs[i-1].mc + "<br/>"
									+ " <label>联系电话 ：</label>" + data.addrs[i-1].dh  + "<br/>"
									+ " <label>详细地址 ：</label>" + (data.addrs[i-1].dz).replace(new RegExp(',','gm'),'')
									+ " </p>";
		    				}else{
		    					html +="<p>"
									+ " <b> 地址"+ i +" </b>："
									+ " <input type=\"checkbox\" id=\"box"+ i + "\" class=\"addr_checkbox\" onclick=\"selectAddr("+ i + ")\"/><br/>"
									+ " <label>收货人姓名 ：</label>" + data.addrs[i-1].mc + "<br/>"
									+ " <label>联系电话 ：</label>" + data.addrs[i-1].dh  + "<br/>"
									+ " <label>详细地址 ：</label>" + (data.addrs[i-1].dz).replace(new RegExp(',','gm'),'')
									+ " </p>";
		    				}
	    				}
	    			}
	    			$("#dzlist").html(html);
	    		}else{
	    			$("#dzlist").html("");
	    			selectAddr(0);
	    		}

		    	if(data.bill != null){
		    		$("#kp_mc").val(data.bill.mc);
		    		if(data.bill.sh != 'null')
		    			$("#kp_sh").val(data.bill.sh);
		    		if(data.bill.dzdh != 'null')
		    			$("#kp_dzdh").val(data.bill.dzdh);
		    		if(data.bill.khh != 'null')
		    			$("#kp_khh").val(data.bill.khh);
		    		if(data.bill.sh != 'null' || data.bill.dzdh != 'null' || data.bill.khh != 'null'){
		    			selectKpxz(2);
		    		}else{
		    			selectKpxz(1);
		    		}
		    	}else{
		    		selectKpxz(1);
		    	}
	    	}
	    }
	    var content = {"orderid":_orderid,"openid":_openid};
	    apiAjax(JSON.stringify(content),url.zcdzurl,callback);
   	}

   	var qr;
   	var time;


   	utils = {
		    setParam : function (name,value){
		        localStorage.setItem(name,value)
		    },
		    getParam : function(name){
		        return localStorage.getItem(name)
		    }
		}

   				cart = {
			    //向购物车中添加商品
			    addproduct:function(product){
			        var ShoppingCart = utils.getParam("ShoppingCart");
			        if(ShoppingCart==null||ShoppingCart==""){
			                        //第一次加入商品
			            var jsonstr = {"productlist":[{"dm":product.dm,"spmc":product.spmc,"sl":product.sl,"price":product.price}],"totalNumber":product.sl,"totalAmount":(product.price*product.sl)};
			            utils.setParam("ShoppingCart",JSON.stringify(jsonstr));
			        }else{
			            var jsonstr = JSON.parse(ShoppingCart);
			            var productlist = jsonstr.productlist;
			            var result=false;
			            //查找购物车中是否有该商品
			            for(var i in productlist){
			                if(productlist[i].dm==product.dm){
			                    productlist[i].sl=parseInt(productlist[i].sl)+parseInt(product.sl);
			                    result = true;
			                }
			            }
			            if(!result){
			                //没有该商品就直接加进去
			                productlist.push({"dm":product.dm,"spmc":product.spmc,"sl":product.sl,"price":product.price});
			            }
			                        //重新计算总价
			            jsonstr.totalNumber=parseInt(jsonstr.totalNumber)+parseInt(product.sl);
			//          jsonstr.totalAmount=parseFloat(jsonstr.totalAmount)+(parseInt(product.num)*parseFloat(product.price));
			            jsonstr.totalAmount=accAdd(jsonstr.totalAmount, accMul(product.sl, product.price));
			            orderdetail.totalNumber = jsonstr.totalNumber;
			            orderdetail.totalAmount = jsonstr.totalAmount;
			            //保存购物车
			            utils.setParam("ShoppingCart",JSON.stringify(jsonstr));
			        }
			    },

			    //修改给买商品数量
			    updateproductnum:function(dm,num){
			        var ShoppingCart = utils.getParam("ShoppingCart");
			        var jsonstr = JSON.parse(ShoppingCart);
			        var productlist = jsonstr.productlist;
			        for(var i in productlist){
			            if(productlist[i].dm==dm){
			                jsonstr.totalNumber=parseInt(jsonstr.totalNumber)+(parseInt(num)-parseInt(productlist[i].sl));
			//              jsonstr.totalAmount=parseFloat(jsonstr.totalAmount)+((parseInt(num)*parseFloat(productlist[i].price))-parseInt(productlist[i].num)*parseFloat(productlist[i].price));
			                jsonstr.totalAmount=accAdd(jsonstr.totalAmount, accSub(accMul(num, productlist[i].price), accMul(productlist[i].sl, productlist[i].price)));
			                productlist[i].sl=parseInt(num);
			                orderdetail.totalNumber = jsonstr.totalNumber;
			                orderdetail.totalAmount = jsonstr.totalAmount;
			                utils.setParam("ShoppingCart",JSON.stringify(jsonstr));
			                return;
			            }
			        }
			    },

			    //获取购物车中的所有商品
			    getproductlist:function(){
			        var ShoppingCart = utils.getParam("ShoppingCart");
			        if (!ShoppingCart) {
			                return null;
			        }
			        var jsonstr = JSON.parse(ShoppingCart);
			        var productlist = jsonstr.productlist;
			        orderdetail.totalNumber = jsonstr.totalNumber;
			        orderdetail.totalAmount = jsonstr.totalAmount;
			        return productlist;
			    },

			    //获取整个购物车
			    getshopcart:function(){
			            var ShoppingCart = utils.getParam("ShoppingCart");
			            return ShoppingCart;
			    },

			    //判断购物车中是否存在商品
			    existproduct:function(id){
			        var ShoppingCart = utils.getParam("ShoppingCart");
			        var jsonstr = JSON.parse(ShoppingCart);
			        var productlist = jsonstr.productlist;
			        var result=false;
			        for(var i in productlist){
			            if(productlist[i].dm==dm){
			                result = true;
			            }
			        }
			        return result;
			    },

			    // 通过id获取商品
			    getproductbyid:function(id) {
			            var ShoppingCart = utils.getParam("ShoppingCart");
			        var jsonstr = JSON.parse(ShoppingCart);
			        var productlist = jsonstr.productlist;
			        var result=false;
			        for(var i in productlist){
			            if(productlist[i].dm==dm){
			                return productlist[i];
			            }
			        }
			        return null;
			    },
			    //删除购物车中商品
			    deleteproduct:function(id){
            api.actionSheet({
                title: '是否删除商品',
                cancelTitle: '取消',
                buttons: ['删除']
            }, function(ret, err){
              if(ret.buttonIndex==1){
                var ShoppingCart = utils.getParam("ShoppingCart");
  			        var jsonstr = JSON.parse(ShoppingCart);
  			        var productlist = jsonstr.productlist;
  			        var list=[];
  			        for(var i in productlist){
  			            if(productlist[i].dm==id){
  			                jsonstr.totalNumber=parseInt(jsonstr.totalNumber)-parseInt(productlist[i].sl);
  			//              jsonstr.totalAmount=parseFloat(jsonstr.totalAmount)-parseInt(productlist[i].num)*parseFloat(productlist[i].price);
  			                jsonstr.totalAmount=accSub(jsonstr.totalAmount, accMul(productlist[i].sl, productlist[i].price));
  			            }else{
  			                list.push(productlist[i]);
  			            }
  			        }
  			        jsonstr.productlist = list;
  			        orderdetail.totalNumber = jsonstr.totalNumber;
  			        orderdetail.totalAmount = jsonstr.totalAmount;
  			        utils.setParam("ShoppingCart",JSON.stringify(jsonstr));
  			        window.location.reload();
              }
            });
			    },
			    //清空购物车
			    clear:function(){

                       utils.setParam("ShoppingCart", "");


			    }
			};

    function goMain(){
     api.closeWin();
      //cart.clear();
    }
    
    var mo=function(e){e.preventDefault();};
    
    function payMethod(){
         var amc1 = "";
         var adh1 = "";
         var adz1 = "";
         var allPrice1 = 0;
          if($("#sfkp1").is(":checked") && $("#kpxz2").is(":checked")){
               var sh = $("#kp_sh").val();
               if(sh == "" || sh == null || sh == "undefined"){
                  $("#loadingToast").hide();
                  alert("请输入税号！");
                  return;
               }
            }
         if(seli ==0){
   			amc1 = $("#sh_mc").val();
   	  		adh1 = $("#sh_dh").val();
   	  		adz1 = $("#sh_dz").val();
	   	  	if(amc1 =="" || adh1 =="" || adz1 ==""){
	   	  		$("#loadingToast").hide();
	  			alert("请完善必填项！");
	  			return;
	  		}
	  		if(amc1.length > 10){
	  			$("#loadingToast").hide();
	  			alert("收货人姓名过长！");
	  			return;
	  		}
	  		if(adh1.length > 12){
	  			$("#loadingToast").hide();
	  			alert("联系电话过长！");
	  			return;
	  		}
	  		if(adz1.length > 100){
	  			$("#loadingToast").hide();
	  			alert("详细地址过长！");
	  			return;
	  		}
           
	  		var adz = $("#address_sheng").find("option:selected").text() + $("#address_shi").find("option:selected").text() + "," + $("#address_qx").find("option:selected").text()  + "," + adz1;
	  		var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
	  		if(num == 0){ 
	  		    adz1 = adz;
	  		    allPrice1 = allPrice;
	  		}else{
	  		    adz1 = adz;
	  		    allPrice1 = parseInt(allPrice)+12;
	  		}
   		}else{
   			var num = dzObj[seli-1].dz.indexOf("四川");
	  		if(num == 0){
	  		    amc1 = dzObj[seli-1].mc;
	  		    adh1 = dzObj[seli-1].dh;
	  		    adz1 = dzObj[seli-1].dz;
	  		    allPrice1 = allPrice;
	  		}else{
	  		    amc1 = dzObj[seli-1].mc;
	  		    adh1 = dzObj[seli-1].dh;
	  		    adz1 = dzObj[seli-1].dz;
	  		    allPrice1 = parseInt(allPrice)+12;
	  		}
   		}
	  		var bmc = $("#kp_mc").val();
	  		if($("#sfkp1").attr("checked")){
	  			if(bmc == ''){
	  	  			$("#loadingToast").hide();
	  	  			alert("发票抬头不能为空！");
	  	  			return;
	  	  		}
	  	  		if(bmc.length > 50){
	  	  			$("#loadingToast").hide();
	  	  			alert("发票抬头过长！");
	  	  			return;
	  	  		}
	  		}else{
	  			bmc = "个人";
	  		}
	
	  		if($("#kp_sh").val().length >30){
	  			$("#loadingToast").hide();
		  			alert("税号过长！");
		  			return;
	  		}
	  		if($("#kp_dzdh").val().length >50){
	  			$("#loadingToast").hide();
		  			alert("地址电话过长！");
		  			return;
	  		}
	  		if($("#kp_khh").val().length >30){
	  			$("#loadingToast").hide();
		  			alert("开户行账号过长！");
		  			return;
	  		}
     var width = document.documentElement.clientWidth;
	 var height = document.documentElement.clientHeight;
	 var hh = document.body.scrollHeight;
	 if(api.systemType == "android"){
	    $api.setStorage("frame","paymethod");
	    $('html').addClass('noscroll');
	 }else{
	    $("body").on("touchmove",function(event){
		event.preventDefault;
		}, false)
	 }
	 if($("#sfkp2").is(":checked")){
	    bmc = "";
	 }
	 document.getElementById("bg").style.height = hh+"px";
	 document.getElementById("bg").style.display="";
	 api.openFrame({
		    name: 'zffs',
		    url: './paymethod.html',
		    rect: {
			    x:0,
			    y:height*0.6,
			    w:width,
			    h:height*0.4
		    },
		    pageParam: {
		       allspmc : allspmc,
		       orderid : orderid,
		       dzObj : dzObj,
		        bmc : bmc,
		        seli : seli,
		        amc : amc1,
	   	  		adh : adh1,
	   	  		adz : adz1,
	   	  		bsh :$("#kp_sh").val(),
		    	bdzdh :$("#kp_dzdh").val(),
		    	bkhh :$("#kp_khh").val(),
		    	bfplx :$("#kp_fplx").val(),
		    	zje : allPrice1
		    }
	    });
    }

        function funcGoto(){
        if(api.systemType == "android"){
            $('html').removeClass('noscroll');
        }else{
            $("body").off("touchmove");
        }        
	     document.getElementById("bg").style.display="none";
	    }
	    
	    function funcGoto1(){
        if(api.systemType == "android"){
            $('html').removeClass('noscroll');
        }else{
            $("body").off("touchmove");
        }        
	     document.getElementById("bg").style.display="none";
	     api.closeToWin({
	     name: 'root'
         });
	    }
	    
	    
	    function show(){
	     $("#loadingToast").show();
	    }
	     
	    function hide(){
	     $("#loadingToast").hide();
	    } 
	    
	    
	   function uPay(){
	     var amc1 = "";
         var adh1 = "";
         var adz1 = "";
         var allPrice1 = 0;
         if(seli ==0){
   			amc1 = $("#sh_mc").val();
   	  		adh1 = $("#sh_dh").val();
   	  		adz1 = $("#sh_dz").val();
   	  		if(amc1 =="" || adh1 =="" || adz1 ==""){
	   	  		$("#loadingToast").hide();
	  			alert("请完善必填项！");
	  			return;
	  		}
	  		if(amc1.length > 10){
	  			$("#loadingToast").hide();
	  			alert("收货人姓名过长！");
	  			return;
	  		}
	  		if(adh1.length > 12){
	  			$("#loadingToast").hide();
	  			alert("联系电话过长！");
	  			return;
	  		}
	  		if(adz1.length > 100){
	  			$("#loadingToast").hide();
	  			alert("详细地址过长！");
	  			return;
	  		}

	  		adz = $("#address_sheng").find("option:selected").text() + $("#address_shi").find("option:selected").text() + "," + $("#address_qx").find("option:selected").text()  + "," + adz1;
	  		var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
	  		if(num == 0){
	  		    adz1 = adz;
	  		    allPrice1 = allPrice;
	  		}else{
	  		    adz1 = adz;
	  		    allPrice1 = parseInt(allPrice)+12.00;
	  		}
	  	}else{
   			var num = dzObj[seli-1].dz.indexOf("四川");
	  		if(num == 0){
	  		    amc1 = dzObj[seli-1].mc;
	  		    adh1 = dzObj[seli-1].dh;
	  		    adz1 = dzObj[seli-1].dz;
	  		    allPrice1 = allPrice;
	  		}else{
	  		    amc1 = dzObj[seli-1].mc;
	  		    adh1 = dzObj[seli-1].dh;
	  		    adz1 = dzObj[seli-1].dz;
	  		    allPrice1 = parseInt(allPrice)+12.00;
	  		}
   		}
	  		var bmc = $("#kp_mc").val();
	  		if($("#sfkp1").attr("checked")){
	  			if(bmc == ''){
	  	  			$("#loadingToast").hide();
	  	  			alert("发票抬头不能为空！");
	  	  			return;
	  	  		}
	  	  		if(bmc.length > 50){
	  	  			$("#loadingToast").hide();
	  	  			alert("发票抬头过长！");
	  	  			return;
	  	  		}
	  		}else{
	  			bmc = "个人";
	  		}
	
	  		if($("#kp_sh").val().length >30){
	  			$("#loadingToast").hide();
		  			alert("税号过长！");
		  			return;
	  		}
	  		if($("#kp_dzdh").val().length >50){
	  			$("#loadingToast").hide();
		  			alert("地址电话过长！");
		  			return;
	  		}
	  		if($("#kp_khh").val().length >30){
	  			$("#loadingToast").hide();
		  			alert("开户行账号过长！");
		  			return;
	  		}
     var width = document.documentElement.clientWidth;
	 var height = document.documentElement.clientHeight;
	 var hh = document.body.scrollHeight;
	 if(api.systemType == "android"){
	    $api.setStorage("frame","paymethod");
	    $('html').addClass('noscroll');
	 }else{
	    $("body").on("touchmove",function(event){
		event.preventDefault;
		}, false)
	 }
	 document.getElementById("bg").style.height = hh+"px";
	 document.getElementById("bg").style.display="";
	 $api.setStorage("frame","");
	 $api.setStorage("upay","unionpay");
		api.openFrame({
		    name: 'ylzff',
		    url: './unionpay.html',
		    rect: {
			    x:0,
			    y:height*0.4,
			    w:width,
			    h:height*0.6
		    },
		    pageParam: {
		       allspmc : allspmc,
		       orderid : orderid,
		       dzObj : dzObj,
		        bmc : bmc,
		        seli : seli,
		        amc : amc1,
	   	  		adh : adh1,
	   	  		adz : adz1,
	   	  		bsh :$("#kp_sh").val(),
		    	bdzdh :$("#kp_dzdh").val(),
		    	bkhh :$("#kp_khh").val(),
		    	bfplx :$("#kp_fplx").val(),
		    	zje : allPrice1
		    }
	    });
	  }
	  
	function closeTj(){
	  api.closeFrame({
	   name:'zffs'
      });
	  api.closeWin({});
	}    
  	  </script>
</html>
